<!--
 * @Descripttion: 打印按钮
-->

<template>
	<div class="sc-button">
		<el-button type="warning" plain v-auth="auth" :disabled="selectionList.length <= 0" @click="batch_check">审核</el-button>
	</div>
	<check-status v-if="check" ref="checkDialog" @success="handleSuccessCheck" @closed="check = false" :apiObj="apiObj" :params="paramsForm" draggable></check-status>
</template>

<script>

import CheckStatus from "./checkStatus.vue";

export default {
	components: {CheckStatus},
	props: {
		selection: {type: Array, default: () => ([])},
		apiObj: {type: Object, default: () => {}},
		auth: {type: String, default: ''},
		params: { type: Object, default: () => ({}) },
	},
	data() {
		return {
			check: false,
			selectionList: this.selection,
			paramsForm:this.params
		}
	},
	// 监控data中的数据变化
	watch: {
		'selection'(val) {
			this.selectionList = val
		}
	},
	created() {

	},
	methods: {
		/**审核成功事件*/
		handleSuccessCheck() {
			this.$emit('checkSuccess')
		},
		/**审核*/
		async batch_check() {
            console.log('this.selectionList :>> ', this.selectionList);
			var ids = [];
			this.selectionList.forEach((item) => {
				ids.push(item.id)
			})
			this.check = true
			this.$nextTick(() => {
				this.$refs.checkDialog.open('add').setData(ids)
			})
		},
	}
}
</script>

<style scoped>
.sc-button {
	margin-left: 12px;
}
</style>
